SLS Lecture 3 : I/O, Process Control and Credentials

SLS Lecture 3 : I/O, Process Control and Credentials

Running and Managing Programs (Commands)

Processes, Files and Streams

  • What is a process in more detail and what can it do

    • a running program

      • process can launch another processes

        • bash is implemented to start commands as process (when needed)

        • passes command line arguments and environment variables

    • Processes, Files and channel/stream model of I/O

      • files and Kernel objects

        • read, write

        • everything is a file

      • Streams: Processes and Files

        • open : attach a file as a stream

        • file descriptors/handles : stream

          • read and write bytes to a stream

          • close

          • dup

        • standard input, standard output, standard error

      • Shell Syntax:

        • echo 'Hello world' > hello

        • cat hello

        • cat < ./hello

    • We now can understand what a pipe is

      • pipe file object

      • Process 1 stdout into pipe and Process 2 stdin from pipe

      • Shell Syntax:

        • ‘ls -1 | wc -l’

        • ‘ls -1 | grep ‘^l*’ | wc -l’

        • mknod mypipe p and mkfifo mypipe

Credentials and file permissions

  • Process have id’s associated with them

    • a single user id : id

      • a single number that maps to a string user name (/etc/passwd)

    • set of group ids

      • user has a primary group but can be in many secondary groups

      • each has a number that maps to a name (/etc/group)

      • each group can have many users

    • ps auxgww

      • process’s inherit their ids from their parent

  • Files have id’s and permissions ls -l, chmod, chown, and chgrp

    • user, group, other -> read, write, execute

    • kernel ensures that process id’s and requested operations match permissions

  • Process management

    • ps - look at all processes

    • The shell and its children

      • & : foreground and background

      • ctrl-z

      • jobs

    • so we know how to start process, list them how about stopping

    • kill

      • signals

      • ctrl-c

      • or without prejudice